﻿
<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%> 
<%@ page import="com.hitrust.gs.dao.*"%> 
<%@ page import="java.util.*"%> 
<%@ include file="/framework/head.jsp"%>


<!--********************* Part2:Java Code *********************-->
<%
    Warehouse warehouse = (Warehouse)context.getSessionValue("WarehouseDetail");
    List customerList = (List)context.getSessionValue("all");
    List yes = (List)context.getSessionValue("yes");
%>

<!--********************* Part3:JavaScript Code ***************-->
<script language="javascript">

function doSearch()
{   
	if(frm.productType.value==''){
	  alert("请选择一个分类");
	  return;
    }
	SetAction("toOrderCategory");
	frm.submit();
}
function doSave()
{
	SetAction("saveOrderCategory");
	frm.submit();
}
function doCancel()
{
	SetAction("backListWarehouse");
	frm.submit();
}
function doCheck(obj){
    //获得首选checkbox的value
    var str = obj.value;
    //获得首选checkbox的长度
    var len = str.length;
    //获得所有的input元素
    var inputs = document.getElementsByTagName("input");
    //获取input元素数组长度
    var inputsLen = inputs.length;   
    //遍历数组  
    for(var i=0;i<inputsLen;i++){
        //过滤条件目的得到仅需的checkbox对象       
        if((inputs[i].type=="checkbox") && (inputs[i].name=="CustomerCode")){
            //获取已过滤对象的value
            var inputCheckBoxValue = inputs[i].value;
            //进行字符串提取比较
            if(inputCheckBoxValue.length > len){
                if(inputCheckBoxValue.substr(0,len) == str){
                    if(obj.checked == true){
                        inputs[i].checked = true;    
                    }else{
                        inputs[i].checked = false;
                    }
                }  
            }                 
        } 
    }
}

key_InitDefault();
key_RegSubmitHandler(doSave);
</script>

<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->

<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code">
<input type=hidden name="Id" value="<%=warehouse.getId()%>">
<input type=hidden name="warehouseCode" value="<%=warehouse.getCode()%>">
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				
				<tr height=20>
                    <td class="bg_column" align=center width="100">分类</td>
                    <td align=left class="bg_row_odd" >
                    	<select name="productType">
                    	<%
                    	String productType = (String)context.getSessionValue("productType"); 
            			GSProductTypeManagerDao proTypeManagerDao= new GSProductTypeManagerDao();
            			Conditions conditions = new Conditions();
            			conditions.add(" upper_type = 2000");
            			conditions.add(" status='1' order by product_type ");
          		        DBConnection c = null;
            			ObjectList  bidTypeList = ObjectList.getList();
            			try{
            				con = DBConnection.open();
            				bidTypeList = ProductTypeManager.fetch().search(con,conditions);
            			}finally{
            				if(con!=null){
            					con.close();
            				}
            			}	 
            		
            			 if(productType==null){
                         	%>
                         		<option value="">---全部---</option>
                         				<%						for(int i=0;i<bidTypeList.size();i++){
     									ProductTypeManager productTypeManager = (ProductTypeManager)bidTypeList.get(i);
     								 %>
     										<option value="<%=productTypeManager.getProductType() %>" ><%=productTypeManager.getTypeName() %></option>
     								<%
     									}
     								 %>
                         		<%}else{ %>
                         		 <option value="">---全部---</option>
     <%							for(int i=0;i<bidTypeList.size();i++){
     									ProductTypeManager productTypeManager = (ProductTypeManager)bidTypeList.get(i);
     								 %>
     										<option value="<%=productTypeManager.getProductType() %>"  <%if(productTypeManager.getProductType().equals(String.valueOf(productType))) {%> selected="selected"<%} %> ><%=productTypeManager.getTypeName() %></option>
     								<%
     									}
     								 %>
                         		<%} %>
                         	
                         	</select>

                    </td> 
                    <td><input type=button class="buttons" value="   查询  " onclick="doSearch();return false;"></td>                 
                </tr>
</table>
</td></tr>
</table>


<%=UIManager.addEditHeadTitle(warehouse.getName()+"-----分类供应商申购设置")%>


<!--********************* Part5:Edit Area  ***************-->
<%=uiEditStart%>>
<%
	int key_tab = 1 ;
    if(customerList!=null){
    for(int i=0;i<customerList.size();i++)
    {
        Provider customer = (Provider)customerList.get(i);
        boolean check=false;
        for(int j=0;j<yes.size();j++){
        	Provider provider = (Provider)yes.get(j);
        	if(provider.getCode().equals(customer.getCode())){
        		check=true;
        		break;
        	}
        }
%>
    <%=uiEditTR%>>
        <%=uiEditTD%>>
            <%=SelectManager.getDiffNum(customer.getCode())%>
                <input type=checkbox name="CustomerCode" value="<%=customer.getCode()%>" <%=check==true?"checked":""%> onclick="doCheck(this);"<%=check==true?"checked":""%>>
            <%=customer.getName() %>（<%=customer.getCode() %>）
        </td>
    </tr>
<%  } }%>	
<%=uiEditEnd%>

<!--********************* Part6:Action Area  ***************-->
<%=uiCommandStart%>>
	<%=uiCommandTR%>>
   		<%=uiCommandTD%>>
			<input type=button class="buttons" value="   保存   " onclick="doSave();return false;">
			<input type=button class="buttons" value="   返回   " onclick="doCancel();return false;">
		</td>
	</tr>
<%=uiCommandEnd%>
</form>

<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :Wing
	FileName  :/system/base/OrderCategory.jsp
-->
